<template>
    <div>
        <span>获取验证码({{time}})</span>
    </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'

const $emit = defineEmits(['close-flag'])

// 倒计时时间
const time = ref(5)

onMounted(() => {
    const timer = setInterval(() => {
        time.value--
        if (time.value <= 0) {
            $emit('close-flag')
            clearInterval(timer)

        }
    }, 1000)
})
</script>

<style scoped>

</style>